package org.springblade.common.utils.mq;

import com.alibaba.fastjson.JSONObject;
import com.github.thierrysquirrel.annotation.CommonMessage;
import com.github.thierrysquirrel.annotation.RocketMessage;
import com.github.thierrysquirrel.annotation.StartDeliverTime;
import com.github.thierrysquirrel.core.producer.MessageSendType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * User: Jackey
 * Date: 2019/11/27
 * Time: 下午2:17
 * Description:
 */
@Slf4j
@Component
@RocketMessage(groupID = "GID_STOP_ELEVATOR")
public class StopElevatorSend {

	/**
	 * 发送电梯停梯
	 * @param
	 * message {
	 *         msgType: 1-停梯时发送 2-签到时发送 3-维修人员第一次签到选择电梯状态正常 4-维修人员第一次签退选择电梯状态停梯
	 *         contentType: 1-一小时 2-两小时 3-四小时
	 *         planId: 工单id
	 *         elevatorId: 电梯id
	 *         initStatusName: 电梯初始运行状态
	 *         setStatusName: 电梯变更运行状态
	 * }
	 * @return
	 */
	@CommonMessage(topic = "stop_elevator", tag = "elevator_stop_test",messageSendType = MessageSendType.SEND_ASYNC)
	public String sendElevatorStopTestMsg(@StartDeliverTime long startDeliverTime,String message) {
		log.info("===============实时生产消息====================", System.currentTimeMillis());
		JSONObject jsonObject = JSONObject.parseObject(message);
		jsonObject.put("sendMsgType","elevator_stop_test");
		log.info("发送时间:[{}],发送内容:[电梯停梯消息:{}]", LocalDateTime.now(), JSONObject.toJSONString(jsonObject));
		return message;
	}

	/**
	 * 发送电梯停梯
	 * @param
	 * message {
	 *         msgType: 1-停梯时发送 2-签到时发送 3-维修人员第一次签到选择电梯状态正常 4-维修人员第一次签退选择电梯状态停梯
	 *         contentType: 1-一小时 2-两小时 3-四小时
	 *         planId: 工单id
	 *         elevatorId: 电梯id
	 *         initStatusName: 电梯初始运行状态
	 *         setStatusName: 电梯变更运行状态
	 * }
	 * @return
	 */
	@CommonMessage(topic = "stop_elevator", tag = "elevator_stop",messageSendType = MessageSendType.SEND_ASYNC)
	public String sendElevatorStopMsg(@StartDeliverTime long startDeliverTime,String message) {
		log.info("===============实时生产消息====================", System.currentTimeMillis());
		JSONObject jsonObject = JSONObject.parseObject(message);
		jsonObject.put("sendMsgType","elevator_stop");
		log.info("发送时间:[{}],发送内容:[电梯停梯消息:{}]", LocalDateTime.now(), JSONObject.toJSONString(jsonObject));
		return message;
	}

}
